package com.jnevision.leaveearlyrule.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.jnevision.leaveearlyrule.model.LeaveEarlyRule;
import com.jnevision.leaveearlyrule.service.LeaveEarlyRuleServiceImpl;
/**
 * <p>
 * 早退规则 前端控制器
 * </p>
 *
 * @author gavin
 * @since 2019-07-21
 */
@RestController
@RequestMapping("/leaveearlyrules")
public class LeaveEarlyRuleController extends ApiController {

	@Autowired
	private LeaveEarlyRuleServiceImpl leaveEarlyRuleServiceImpl;
	
	@PostMapping
	public R<Boolean> save(@RequestBody LeaveEarlyRule leaveEarlyRule){
		
		return this.success(this.leaveEarlyRuleServiceImpl.save(leaveEarlyRule));
	}
	
	@GetMapping("/groupId")
	public R<LeaveEarlyRule> get(String groupId){
		
		return this.success(this.leaveEarlyRuleServiceImpl.getOne(new QueryWrapper<LeaveEarlyRule>().eq("group_id", groupId)));
	}
}

